package cn.xshi.monitor.service.impl;
import java.util.List;
import java.util.Map;
import cn.xshi.common.base.BaseService;
import cn.xshi.common.util.ExceptionUtil;
import cn.xshi.monitor.dao.IotDeviceConfigDao;
import cn.xshi.monitor.model.IotDeviceConfig;
import cn.xshi.monitor.service.IotDeviceConfigService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
/**
 * @Desc 设备配置
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@Service
public class IotDeviceConfigServiceImpl extends BaseService implements IotDeviceConfigService {

	@Resource
	private IotDeviceConfigDao iotDeviceConfigDao;

	/**
	* 分页
	* @param condition 
	* @return
	*/
	public List<IotDeviceConfig> getIotDeviceConfigListByCondition(Map<String,Object> condition){
		try{
			return iotDeviceConfigDao.getIotDeviceConfigListByCondition(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 查询对象
	* @param device_config_id 
	* @return
	*/
	public IotDeviceConfig getIotDeviceConfigById(String device_config_id){
		try{
			IotDeviceConfig iotDeviceConfig = iotDeviceConfigDao.getIotDeviceConfigById(device_config_id);
			return iotDeviceConfig;
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 添加
	* @param iotDeviceConfig 
	* @return
	*/
	public int addIotDeviceConfig(IotDeviceConfig iotDeviceConfig){
		int i = 0;
		try {
			iotDeviceConfig.setId(toUUID());
			i = iotDeviceConfigDao.addIotDeviceConfig(iotDeviceConfig);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 修改
	* @param iotDeviceConfig 
	* @return
	*/
	public int updateIotDeviceConfig(IotDeviceConfig iotDeviceConfig){
		int i = 0;
		try {
			i = iotDeviceConfigDao.updateIotDeviceConfig(iotDeviceConfig);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 修改（根据动态条件）
	* @param iotDeviceConfig 
	* @return
	*/
	public int updateIotDeviceConfigBySelective(IotDeviceConfig iotDeviceConfig){
		int i = 0;
		try {
			i = iotDeviceConfigDao.updateIotDeviceConfigBySelective(iotDeviceConfig);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 删除
	* @param condition 
	* @return
	*/
	public int delIotDeviceConfig(Map<String,Object> condition){
		int i = 0;
		try {
			i = iotDeviceConfigDao.delIotDeviceConfig(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 批量修改
	* @param iotDeviceConfigList 
	* @return
	*/
	public int updateBatchIotDeviceConfig(List<IotDeviceConfig> iotDeviceConfigList){
		int i = 0;
		try {
			i = iotDeviceConfigDao.updateBatchIotDeviceConfig(iotDeviceConfigList);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 批量修改（根据动态条件）
	* @param iotDeviceConfigList 
	* @return
	*/
	public int updateBatchIotDeviceConfigBySelective(List<IotDeviceConfig> iotDeviceConfigList){
		int i = 0;
		try {
			i = iotDeviceConfigDao.updateBatchIotDeviceConfigBySelective(iotDeviceConfigList);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	 * 根据设备id查找对象
	 * @param device_id
	 * @return
	 */
	public IotDeviceConfig getIotDeviceConfigByDeviceId(String device_id){
		return iotDeviceConfigDao.getIotDeviceConfigByDeviceId(device_id);
	}
}
